﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Modal
{
    public class ResponseData
    {
        public ResponseData(string code, string msg, dynamic data = null) {
            this.code = code;
            this.msg = msg;
            this.data = data;
        }
        private string code;
        private string msg;
        private dynamic data;

        public string Code
        {
            get { return code; }
            set { code = value; }
        }
        public string Msg
        {
            get { return msg; }
            set { msg = value; }
        }
        public dynamic Data
        {
            get
            {
                if (data == null)
                    data = "\"null\"";

                return data;
            }
            set { data = value; }
        }

        public override string ToString() {
            string data= Newtonsoft.Json.JsonConvert.SerializeObject(Data);
            string format= $"\"statusCode\":\"{Code}\",\"msg\":\"{Msg}\",\"Data\":{data}";
            return "{" + format + "}";
        }
    }
}
